package cn.tedu.smartmarketing.admin.controller;

import cn.tedu.smartmarketing.admin.pojo.dto.AdminCheck;
import cn.tedu.smartmarketing.admin.pojo.dto.AdminLoginParam;
import cn.tedu.smartmarketing.admin.pojo.dto.FinanceRecordParam;
import cn.tedu.smartmarketing.admin.pojo.vo.AdminVo;
import cn.tedu.smartmarketing.admin.pojo.vo.ChecksVO;
import cn.tedu.smartmarketing.admin.pojo.vo.FinanceListVO;
import cn.tedu.smartmarketing.admin.service.AdminService;
import cn.tedu.smartmarketing.base.response.JsonResult;
import cn.tedu.smartmarketing.base.response.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/admin")
@Slf4j
public class AdminController {
    @Autowired
    AdminService adminService;
    @PostMapping("/login")
    public JsonResult login(AdminLoginParam adminLoginParam){
        log.debug("管理员登录");
        AdminVo adminVo = adminService.login(adminLoginParam);
        return JsonResult.ok(adminVo);

         //返回成功信息，并携带返回值cod
    }
    @PostMapping("checks")
    public JsonResult checks(  AdminCheck adminCheck){
        log.debug("管理员审核");
        adminService.check(adminCheck);
        return JsonResult.ok();
    }


    @PostMapping("finance/record")
    public JsonResult financeRecord(FinanceRecordParam financeRecordParam){
        log.debug("交易信息：{}",financeRecordParam);
        adminService.financeRecord(financeRecordParam);
        return JsonResult.ok();
    }

    @GetMapping("finance/list/{businessId}")
    public JsonResult financeList(@PathVariable Integer businessId){
        log.debug("查询交易信息id：{}",businessId);
        List<FinanceListVO> list = adminService.financeList(businessId);
        return JsonResult.ok(list);
    }
    @GetMapping("/checks/record")
    public JsonResult listChecksRecord(String businessId) {
        log.debug("商家审核记录查询{}", businessId);
        List<ChecksVO> list = adminService.listChecksRecord(businessId);
        return JsonResult.ok(list);
    }
}
